//
//  LoginViewController.m
//  Beauty
//
//  Created by Snow on 16/8/29.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "LoginViewController.h"
#import "GXMacro.h"
#import "ZWYNetTool.h"
#import "MyViewController.h"
#import "Zhengze.h"
#import "GXNetWorkingParser.h"
#import "SendMBCodeViewController.h"
#import "UIView+Frame.h"
#import "MyViewController.h"
#import "MainViewController.h"
@interface LoginViewController ()<UITextFieldDelegate>
@property (nonatomic, strong) UIButton *buttonOfLogin;
@property (nonatomic, strong) UIButton *buttonOfRegister;
@property (nonatomic, strong) UITextField *textofPassword;
@property (nonatomic, strong) UILabel *labelOfContract;
@property (nonatomic, strong) UILabel *labelOfContracts;
@property (nonatomic, strong) UITextField *textOfName;
@property (nonatomic, strong) UIButton *buttonOfSure;
@property (nonatomic, strong) UIButton *buttonOfMiss;
@property (nonatomic, strong) UIView *viewOfSome;
@property (nonatomic, strong) UIView *viewOfBackImage;
@end

@implementation LoginViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.viewOfBackImage = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT + 64)];
    [self.view addSubview:_viewOfBackImage];
    self.viewOfBackImage.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"loginIn"]];

    //logo_image
    UIImageView *imageOfLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"椭圆-1"]];
    [self.viewOfBackImage addSubview:imageOfLogo];
    [imageOfLogo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.viewOfBackImage.mas_centerX);
        make.centerY.mas_equalTo(self.viewOfBackImage.mas_centerY).multipliedBy(0.4);
        make.width.mas_equalTo(self.viewOfBackImage.mas_width).multipliedBy(0.5);
        make.height.mas_equalTo(self.viewOfBackImage.mas_width).multipliedBy(0.3);
    }];
    
    //关闭页面按钮
    UIButton *buttonOfClose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.viewOfBackImage addSubview:buttonOfClose];
    [buttonOfClose setBackgroundImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [buttonOfClose mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.viewOfBackImage.mas_top).mas_equalTo(50);
        make.right.mas_equalTo(self.viewOfBackImage.mas_right).mas_equalTo(-20);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    [buttonOfClose addTarget:self action:@selector(closeIt:) forControlEvents:UIControlEventTouchUpInside];
    
    //登录按钮
    self.buttonOfLogin = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.buttonOfLogin setTitle:@"账号登录" forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:self.buttonOfLogin];
    [self.buttonOfLogin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(imageOfLogo.mas_bottom).mas_equalTo(50);
        make.left.mas_equalTo(imageOfLogo.mas_left);
        make.width.mas_equalTo(imageOfLogo.mas_width).multipliedBy(0.33);
        make.height.mas_equalTo(20);
    }];
    self.buttonOfLogin.titleLabel.font = [UIFont systemFontOfSize:12];
    self.buttonOfLogin.tintColor = [UIColor whiteColor];
    [self.buttonOfLogin addTarget:self action:@selector(login:) forControlEvents:UIControlEventTouchUpInside];
    
    //注册按钮
    self.buttonOfRegister = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.buttonOfRegister setTitle:@"立即注册" forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:self.buttonOfRegister];
    [self.buttonOfRegister mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(imageOfLogo.mas_bottom).mas_equalTo(50);
        make.right.mas_equalTo(imageOfLogo.mas_right);
        make.width.mas_equalTo(imageOfLogo.mas_width).multipliedBy(0.33);
        make.height.mas_equalTo(20);
    }];
    self.buttonOfRegister.titleLabel.font = [UIFont systemFontOfSize:12];
    self.buttonOfRegister.tintColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    [self.buttonOfRegister addTarget:self action:@selector(pressRegister:) forControlEvents:UIControlEventTouchUpInside];
    
//    //viewOfTextName
    UIView *viewOfTextName = [[UIView alloc] init];
    viewOfTextName.backgroundColor = [UIColor colorWithWhite:0.702 alpha:0.705];
    [self.viewOfBackImage addSubview:viewOfTextName];
    [viewOfTextName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.buttonOfLogin.mas_left);
        make.right.mas_equalTo(self.buttonOfRegister.mas_right);
        make.height.mas_equalTo(20);
        make.top.mas_equalTo(self.buttonOfLogin.mas_bottom).mas_equalTo(30);
    }];
    viewOfTextName.layer.masksToBounds = YES;
    viewOfTextName.layer.cornerRadius = 10;
    viewOfTextName.layer.borderWidth = 1;
    viewOfTextName.layer.borderColor = [[UIColor whiteColor] CGColor];
    
//    viewOfTextPassword
    UIView *viewOfTextPassword = [[UIView alloc] init];
    viewOfTextPassword.backgroundColor = [UIColor colorWithWhite:0.800 alpha:0.697];
    [self.viewOfBackImage addSubview:viewOfTextPassword];
    [viewOfTextPassword mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.buttonOfLogin.mas_left);
        make.right.mas_equalTo(self.buttonOfRegister.mas_right);
        make.height.mas_equalTo(20);
        make.top.mas_equalTo(viewOfTextName.mas_bottom).mas_equalTo(30);
    }];
    viewOfTextPassword.layer.masksToBounds = YES;
    viewOfTextPassword.layer.cornerRadius = 10;
    viewOfTextPassword.layer.borderWidth = 1;
    viewOfTextPassword.layer.borderColor = [[UIColor whiteColor] CGColor];
    
    //UITextfieldOfname
    
    self.textOfName = [[UITextField alloc] init];
    [self.viewOfBackImage addSubview:self.textOfName];
    self.textOfName.borderStyle = UITextBorderStyleNone;
    self.textOfName.placeholder = @"账号";
    self.textOfName.delegate = self;
    self.textOfName.font = [UIFont systemFontOfSize:12];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];//新建可变字典
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];//设置颜色属性
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:self.textOfName.placeholder attributes:dict];
    [self.textOfName setAttributedPlaceholder:attribute];
    [self.textOfName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.buttonOfLogin.mas_left).mas_equalTo(10);
        make.right.mas_equalTo(self.buttonOfRegister.mas_right).mas_equalTo(5);
        make.height.mas_equalTo(20);
        make.top.mas_equalTo(self.buttonOfLogin.mas_bottom).mas_equalTo(30);
    }];
    
    //UITextfieldOfPassword
   self.textofPassword = [[UITextField alloc] init];
    [self.viewOfBackImage addSubview:self.textofPassword];
    self.textofPassword.borderStyle = UITextBorderStyleNone;
    self.textofPassword.placeholder = @"请输入密码";
    self.textofPassword.font = [UIFont systemFontOfSize:12];
    NSMutableDictionary *dict1 = [NSMutableDictionary dictionary];//新建可变字典
    dict1[NSForegroundColorAttributeName] = [UIColor whiteColor];//设置颜色属性
    NSAttributedString *attribute1 = [[NSAttributedString alloc] initWithString:self.textofPassword.placeholder attributes:dict1];
    [self.textofPassword setAttributedPlaceholder:attribute1];
    self.textofPassword.secureTextEntry = YES;
    self.textofPassword.delegate = self;
    [self.textofPassword mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.buttonOfLogin.mas_left).mas_equalTo(10);
        make.right.mas_equalTo(self.buttonOfRegister.mas_right).mas_equalTo(-30);
        make.height.mas_equalTo(20);
        make.top.mas_equalTo(viewOfTextName.mas_bottom).mas_equalTo(30);
    }];
    //上面的switch
    UISwitch *switchOfPassword = [[UISwitch alloc] init];
    switchOfPassword.onTintColor = [UIColor clearColor];
    switchOfPassword.tintColor = [UIColor whiteColor];
    switchOfPassword.thumbTintColor = [UIColor lightGrayColor];
    [switchOfPassword addTarget:self action:@selector(switcAction:) forControlEvents:UIControlEventValueChanged];
    switchOfPassword.transform = CGAffineTransformMakeScale(0.35, 0.35);
    [self.viewOfBackImage addSubview:switchOfPassword];
    [switchOfPassword mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.textofPassword.mas_right);
        make.right.mas_equalTo(viewOfTextPassword.mas_right).mas_equalTo(-10);
        make.height.mas_equalTo(10);
        make.top.mas_equalTo(viewOfTextName.mas_bottom).mas_equalTo(32);
    }];

        //确定按钮
    self.buttonOfSure = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonOfSure.backgroundColor = [UIColor colorWithWhite:0.902 alpha:0.809];
    self.buttonOfSure.layer.masksToBounds = YES;
    self.buttonOfSure.layer.cornerRadius = 10;
    self.buttonOfSure.layer.borderColor = [[UIColor whiteColor] CGColor];
    self.buttonOfSure.layer.borderWidth = 1;
    [self.buttonOfSure setTitle:@"确定" forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:self.buttonOfSure];
    [self.buttonOfSure mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(viewOfTextPassword.mas_bottom).mas_equalTo(30);
        make.left.mas_equalTo(viewOfTextName.mas_left);
        make.right.mas_equalTo(viewOfTextName.mas_right);
        make.height.mas_equalTo(20);
    }];
    self.buttonOfSure.titleLabel.font = [UIFont systemFontOfSize:12];
    self.buttonOfSure.tintColor = [UIColor whiteColor];
    [self.buttonOfSure addTarget:self action:@selector(sure:) forControlEvents:UIControlEventTouchUpInside];
    //忘记密码按钮
    self.buttonOfMiss = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonOfMiss.tintColor = [UIColor whiteColor];
    [self.buttonOfMiss setTitle:@"忘记密码?" forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:self.buttonOfMiss];
    [self.buttonOfMiss mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.buttonOfSure.mas_bottom).mas_equalTo(30);
        make.left.mas_equalTo(self.buttonOfSure.mas_left);
        make.right.mas_equalTo(self.buttonOfSure.mas_right);
        make.height.mas_equalTo(20);
    }];
    self.buttonOfMiss.titleLabel.font = [UIFont systemFontOfSize:12];
    
    //其他账号登录 按钮
    UIView *viewOfWechat = [[UIView alloc] init];
    [self.viewOfBackImage addSubview:viewOfWechat];
    viewOfWechat.backgroundColor = [UIColor whiteColor];
    viewOfWechat.layer.masksToBounds = YES;
    viewOfWechat.layer.cornerRadius = 20;
    [viewOfWechat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.viewOfBackImage.mas_centerX);
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40);
    }];
    UIButton *buttonOfWechat = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttonOfWechat setImage:[UIImage imageNamed:@"login_wechat"] forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:buttonOfWechat];
    [buttonOfWechat mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.viewOfBackImage.mas_centerX);
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-25);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(30);
    }];
    
    UIView *viewOfQQ = [[UIView alloc] init];
    [self.viewOfBackImage addSubview:viewOfQQ];
    viewOfQQ.backgroundColor = [UIColor whiteColor];
    viewOfQQ.layer.masksToBounds = YES;
    viewOfQQ.layer.cornerRadius = 20;
    [viewOfQQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40);
        make.right.mas_equalTo(buttonOfWechat.mas_left).mas_equalTo(-20);
    }];
    
    UIButton *buttonOfQQ = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttonOfQQ setImage:[UIImage imageNamed:@"login_qq"] forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:buttonOfQQ];
    [buttonOfQQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-25);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(30);
        make.right.mas_equalTo(buttonOfWechat.mas_left).mas_equalTo(-25);
    }];
    [buttonOfQQ setImage:[UIImage imageNamed:@"login_qq"] forState:UIControlStateNormal];
    
    UIView *viewOfBlog = [[UIView alloc] init];
    [self.viewOfBackImage addSubview:viewOfBlog];
    viewOfBlog.backgroundColor = [UIColor whiteColor];
    viewOfBlog.layer.masksToBounds = YES;
    viewOfBlog.layer.cornerRadius = 20;
    [viewOfBlog mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40);
        make.left.mas_equalTo(buttonOfWechat.mas_right).mas_equalTo(20);
    }];
    UIButton *buttonOfBlog = [UIButton buttonWithType:UIButtonTypeCustom];
    [buttonOfBlog setImage:[UIImage imageNamed:@"login_blog"] forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:buttonOfBlog];
    [buttonOfBlog mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.viewOfBackImage.mas_bottom).mas_equalTo(-25);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(30);
        make.left.mas_equalTo(buttonOfWechat.mas_right).mas_equalTo(25);
    }];
}
//关闭按钮
- (void)closeIt:(UIButton *)button
{

[self dismissViewControllerAnimated:YES completion:^{
}];
}
//账号登录按钮
- (void)login:(UIButton *)button
{
    button.tintColor = [UIColor whiteColor];
    self.buttonOfRegister.tintColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    self.textOfName.placeholder = @"账号";
    [self.buttonOfSure setTitle:@"确定" forState:UIControlStateNormal];
    [self.buttonOfSure removeTarget:self action:@selector(getMBCode:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonOfSure addTarget:self action:@selector(sure:) forControlEvents:UIControlEventTouchUpInside];
    self.buttonOfMiss = [UIButton buttonWithType:UIButtonTypeSystem];
    self.buttonOfMiss.tintColor = [UIColor whiteColor];
    [self.buttonOfMiss setTitle:@"忘记密码?" forState:UIControlStateNormal];
    [self.viewOfBackImage addSubview:self.buttonOfMiss];
    [self.buttonOfMiss mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.buttonOfSure.mas_bottom).mas_equalTo(30);
        make.left.mas_equalTo(self.buttonOfSure.mas_left);
        make.right.mas_equalTo(self.buttonOfSure.mas_right);
        make.height.mas_equalTo(20);
    }];
    self.buttonOfMiss.titleLabel.font = [UIFont systemFontOfSize:12];
    [_labelOfContract removeFromSuperview];
    [_labelOfContracts removeFromSuperview];
    self.textOfName.font = [UIFont systemFontOfSize:12];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];//新建可变字典
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];//设置颜色属性
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:self.textOfName.placeholder attributes:dict];
    [self.textOfName setAttributedPlaceholder:attribute];
}
//立即注册按钮
- (void)pressRegister:(UIButton *)button
{
    self.textOfName.placeholder = @"手机";
    [self.buttonOfSure setTitle:@"下一步" forState:UIControlStateNormal];
    [_buttonOfSure removeTarget:self action:@selector(sure:) forControlEvents:UIControlEventTouchUpInside];
    [_buttonOfSure addTarget:self action:@selector(getMBCode:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonOfMiss removeFromSuperview];
    button.tintColor = [UIColor whiteColor];
    self.buttonOfLogin.tintColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    self.labelOfContract = [[UILabel alloc] init];
    _labelOfContract.text = @"阅读并接受";
    _labelOfContract.textColor = [UIColor whiteColor];
    _labelOfContract.font = [UIFont systemFontOfSize:10];
    [self.viewOfBackImage addSubview:self.labelOfContract];
    [_labelOfContract mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_textofPassword.mas_bottom).mas_equalTo(10);
        make.height.mas_equalTo(10);
        make.left.mas_equalTo(_textofPassword.mas_left).mas_equalTo(10);
        make.width.mas_equalTo(50);
    }];
    _labelOfContracts = [[UILabel alloc] init];
    _labelOfContracts.text = @"<玩艺用户协议>";
    _labelOfContracts.font =[UIFont systemFontOfSize:10];
    _labelOfContracts.textColor = [UIColor colorWithRed:0.329 green:0.702 blue:0.910 alpha:1.000];
    [self.viewOfBackImage addSubview:_labelOfContracts];
    [_labelOfContracts mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_textofPassword.mas_bottom).mas_equalTo(10);
        make.height.mas_equalTo(10);
        make.left.mas_equalTo(_labelOfContract.mas_right);
        make.width.mas_equalTo(80);
    }];
    self.textOfName.font = [UIFont systemFontOfSize:12];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];//新建可变字典
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];//设置颜色属性
    NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:self.textOfName.placeholder attributes:dict];
    [self.textOfName setAttributedPlaceholder:attribute];
}
//确定按钮
- (void)sure:(UIButton *)button
{
    if (![Zhengze isMobile:_textOfName.text]) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入正确的手机号码" message:@"" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:alert animated:YES completion:^{
        }];
        // 移除
        [alert dismissViewControllerAnimated:YES completion:^{
        }];
    } else {
        if (_textofPassword.text.length < 6 || _textofPassword.text.length > 17) {
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"密码长度不足" message:@"" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:alert animated:YES completion:^{
            }];
            // 移除
            [alert dismissViewControllerAnimated:YES completion:^{
            }];
        } else {
            NSString *url1 = @"http://www.wantease.com/mobile/index.php?act=login";
            NSString *body = [NSString stringWithFormat:@"client=ios&device_tokens=4eba76addd2f25760d9b6da80c115cb9280e19b5eb37a3a3660d3a1fefa13da5&password=%@&username=%@", _textofPassword.text, _textOfName.text];
            [ZWYNetTool POST:url1 andBody:body andBodyStyle:ZWYBodyString andHeader:@{@"text/html": @"Content-Type",  @"utf-8" :@"charset"}  andResponse:ZWYJSON andSuccessBlock:^(id result) {
                NSLog(@"登录成功");
                
                NSDictionary *dic = result[@"datas"];
                NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
                //登陆成功后把用户名和密码存储到UserDefault
                [userDefaults setObject:dic[@"username"] forKey:@"name"];
                [userDefaults setObject:dic[@"key"] forKey:@"password"];
                [userDefaults synchronize];
//                self.navigationController.navigationBar.hidden = NO;
//                self.tabBarController.tabBar.hidden = NO;
//                MyViewController *my = [[MyViewController alloc] init];
//                [self presentViewController:my animated:YES completion:^{
//                    
//                }];
                
[self dismissViewControllerAnimated:YES completion:^{
    
    }];
            } andFailureBlock:^(NSError *error) {
                }];
        }
    }
}
//获取验证码按钮-下一步
- (void)getMBCode:(UIButton *)button
{
    if (![Zhengze isMobile:_textOfName.text]) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入正确的手机号码" message:@"" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:alert animated:YES completion:^{
        }];
        // 移除
        [alert dismissViewControllerAnimated:YES completion:^{
        }];
    } else {
        if (_textofPassword.text.length < 6 || _textofPassword.text.length > 17) {
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"密码长度不足" message:@"" preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:alert animated:YES completion:^{
            }];
            // 移除
            [alert dismissViewControllerAnimated:YES completion:^{
            }];
        } else {
            SendMBCodeViewController *send = [[SendMBCodeViewController alloc] init];
            send.stringOfPhone = _textOfName.text;
            [self.navigationController pushViewController:send animated:YES];
            NSLog(@"可以注册了 已经发送验证码");
//            NSLog(@"text:%@", _textOfName.text);
//            NSString *url = @"http://www.wantease.com/api/index.php?act=login&op=phone_status&mobile=";
//            NSString *sendmdcode = @"http://www.wantease.com/api/index.php?act=login&op=sendmbcode&mobile=";
//            NSLog(@"%@---%@", [url stringByAppendingString:_textOfName.text], [sendmdcode stringByAppendingString:_textOfName.text]);
//            [GXNetWorkingParser GETWithURL:[url stringByAppendingString:_textOfName.text] par:nil success:^(id responseObject) {
//                NSLog(@"成功:%@", responseObject);
//            } filed:^(NSError *error) {
//                NSLog(@"失败:%@", error);
//            }];
//            [GXNetWorkingParser GETWithURL:[sendmdcode stringByAppendingString:_textOfName.text] par:nil success:^(id responseObject) {
//                NSLog(@"成功:%@", responseObject);
//            } filed:^(NSError *error) {
//                NSLog(@"失败:%@", error);
//            }];
//            
        }
    }
}
//switch开关
- (void)switcAction:(UISwitch *)swit

{
    //根据switch的状态 选择输入密文或明文
    
    if (swit.on == YES) {
        swit.tintColor = [UIColor whiteColor];
        self.textofPassword.secureTextEntry = NO;
        swit.thumbTintColor = [UIColor whiteColor];
    } else {
        self.textofPassword.secureTextEntry = YES;
        swit.thumbTintColor = [UIColor lightGrayColor];
    }
}
//点击return 回收键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    [textField endEditing:YES];
    return YES;
}
//根据键盘高度 调整控件位置
- (void)textFieldDidBeginEditing:(UITextField *)textField
{

}
//关闭按钮
//- (void)close:(UIButton *)button
//{
//    //    [self.navigationController popViewControllerAnimated:YES];
//    /** 跳转到下一个BarButtonItem */
//    //    self.tabBarController.selectedIndex = 0;
//    [self dismissViewControllerAnimated:YES completion:^{
//        
//    }];
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
